/*
 * Problem: A Simple Problem with Integers(POJ 3468)
 * Created: 2022/02/28
 * Author: Yuanshun L
 * Algorithm: BIT
 */

#include<iostream>
#include<string>
using namespace std;
#define qc ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
// input
int N,Q;
const int MAX_N = 1e8 + 5;
ll data[MAX_N],datb[MAX_N];


void add(ll arr[],int k,int x){
    while(k<=N){
        arr[k] += x;
        k += k & -k;
    }
}

ll sum(const ll arr[], int k){
    ll res = 0;
    while(k > 0){
        res += arr[k];
        k -= k & -k;
    }
    return res;
}

void update(int l,int r,int t){
    add(data,l,-t*(l-1));
    add(data,r,t*(r-1));
    add(datb,l,t);
    add(datb,r,-t);
}

void solve(){
    cin >> N >> Q;

    int t;
    for(int i=0;i<N;i++){
        cin >> t;
        add(data,i+1,t);
    }
    string op;
    int l,r,x;
    ll res;
    for(int i=0;i<Q;i++){
        cin >> op >> l >> r;

        if(op[0] == 'Q'){
            res = sum(data,r) + sum(datb,r)*r -(sum(data,l-1) + sum(datb,l-1)*(l-1));
            cout << res << endl;
        }
        else{
            cin >> x;
            update(l,r+1,x);
        }
    }
}

int main(){
    qc;
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    solve();
    return 0;
}
